import { defineConfig } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import path from "path";
import AutoImport from "unplugin-auto-import/vite";
import h5ProdEffectPlugin from "uni-vite-plugin-h5-prod-effect";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    uni(),
    AutoImport({
      imports: ["vue", "uni-app"],
      dirs: ["src/utils", "src/wxs/**"],
      dts: "src/auto-imports.d.ts",
      eslintrc: {
        enabled: true,
      },
    }),
    // 对h5 production环境打包时的特殊处理，否则uni-crazy-router在这个环境会异常
    h5ProdEffectPlugin(),
  ],
  // css: {
  //   preprocessorOptions: {
  //     scss: {
  //       additionalData: `@import "@/theme/var.scss" as *;`,
  //     },
  //   },
  // },
  server: {
    host: true,
    port: 8003,
    open: true,
    // "devServer": {
    //   "disableHostCheck": true,
    //   "port": 80, // 开发端口号

    // }
    proxy: {
      "/dev": {
        target: "https://api-cn.faceplusplus.com/imagepp/v1/mergeface", //目标接口域名 测试
        changeOrigin: true, //是否跨域
        secure: true, // 设置支持https协议的代理
        // rewrite: (path) => path.replace(new RegExp("^" + "/dev"), ""),
        rewrite: (path) => path.replace(new RegExp("^" + "/dev"), ""),
      },
    },
  },
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "src"),
    },
  },
});
